import {
  IsString,
  IsNumber,
  IsBoolean,
  IsDate,
  IsOptional,
  IsEnum,
  IsArray,
  MinLength,
  MaxLength
} from "class-validator";
import { ApiProperty, OmitType, IntersectionType } from '@nestjs/swagger';
import { PagingDto } from 'src/common/dto/index';
import { CharEnum } from 'src/common/enum/index';
import { Type } from 'class-transformer';

export class BaseInfoDto {
  @ApiProperty({ required: false, description: 'user_id' })
  @IsOptional()
  @IsNumber()
  @Type(() => Number)
  userId?: number;

  @ApiProperty({ required: false, description: 'parent_id' })
  @IsOptional()
  @IsNumber()
  @Type(() => Number)
  parentId?: number;

  @ApiProperty({ required: false, description: 'avatar' })
  @IsOptional()
  @IsString()
  avatar?: string;

  @ApiProperty({ required: false, description: '登录账号' })
  @IsOptional()
  @IsString()
  loginAccount?: string;

  @ApiProperty({ required: false, description: '登录密码' })
  @IsOptional()
  @IsString()
  @MinLength(6, { message: '密码长度不能少于6位' })
  loginPassword?: string;

  @ApiProperty({ required: false, description: '孩子昵称' })
  @IsOptional()
  @IsString()
  childNickname?: string;

  @ApiProperty({ required: false, description: '孩子性别' })
  @IsOptional()
  @IsString()
  childGender?: string;

  @ApiProperty({ required: false, description: '性格特点' })
  @IsOptional()
  @IsString()
  personality?: string;

  @ApiProperty({ required: false, description: '兴趣爱好' })
  @IsOptional()
  @IsString()
  hobbies?: string;

  @ApiProperty({ required: false, description: '交流诉求' })
  @IsOptional()
  @IsString()
  communicationAppeal?: string;

  @ApiProperty({ enum: CharEnum, required: false, description: '状态' })
  @IsOptional()
  @IsString()
  status?: string;

  @ApiProperty({ enum: CharEnum, required: false, description: '删除标志' })
  @IsOptional()
  @IsString()
  delFlag?: string;

  @ApiProperty({ required: false, description: '创建时间' })
  @IsOptional()
  @IsArray()
  @IsString({ each: true })
  createTime?: Array<string>;

  @ApiProperty({ required: false, description: '更新时间' })
  @IsOptional()
  @IsArray()
  @IsString({ each: true })
  updateTime?: Array<string>;
}

export class CreateInfoDto extends OmitType(BaseInfoDto, ['delFlag', 'createTime']) {}

export class UpdateInfoDto extends OmitType(BaseInfoDto, ['delFlag', 'createTime']) {}

export class QueryInfoDto extends IntersectionType(BaseInfoDto, PagingDto) {}

export class ListInfoDto extends OmitType(BaseInfoDto, ['delFlag', 'createTime', 'updateTime']) {}
